<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzb.erp.api.pc.student.mapper.StudentCreditLogMapper">

    <select id="getList" resultType="com.hzb.erp.api.pc.student.pojo.StudentCreditLogVO">
        select t1.*
        , t2.name student_name
        from student_credit_log t1
        left join student t2 on t1.student_id = t2.id
        <where>
            <if test="param.studentId != null">
                AND t1.student_id = #{param.studentId}
            </if>
            <if test="param.mobile != null and param.mobile != ''">
                AND t1.user_id = (select id from user where mobile = #{param.mobile})
            </if>
            <if test="param.changeType != null">
                AND t1.change_type = #{param.changeType}
            </if>
            <if test="param.startDate != null and param.endDate != null">
                AND ( date(t1.add_time) &gt;= #{param.startDate} and  date(t1.add_time) &lt;= #{param.endDate} )
            </if>
        </where>
        order by t1.id desc
    </select>

</mapper>
